Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only setup shared pools if we have a connection #45773

Conversation

eileencodes
Copy link
Member

Previously setup_shared_connection_pool was called anytime
setup_fixtures saw a future connection established. Sometimes those
connections are nil but we were setting up the shared pools before
determining that.

This change moves the setup_shared_connection_pool into the check for
if we have a connection. The tests that were dealing with these settings
were originally set to not use transacitons. But without this we can't
test the change here so I've updated that as well.

This is an alternate fix to #45769. I realized after opening the PR it
wasn't quite right to skip if we don't have a writing pool config,
because the question is how were we ending up with that anyway? Well the
answer was that we were calling the shared setup in the wrong place.

Fixes #45767

Previously `setup_shared_connection_pool` was called anytime
`setup_fixtures` saw a future connection established. Sometimes those
connections are `nil` but we were setting up the shared pools before
determining that.

This change moves the `setup_shared_connection_pool` into the check for
if we have a connection. The tests that were dealing with these settings
were originally set to not use transacitons. But without this we can't
test the change here so I've updated that as well.

This is an alternate fix to rails#45769. I realized after opening the PR it
wasn't quite right to skip if we don't have a writing pool config,
because the question is how were we ending up with that anyway? Well the
answer was that we were calling the shared setup in the wrong place.

Fixes rails#45767
@eileencodes eileencodes merged commit 28f5ec6 into rails:main Aug 5, 2022
@eileencodes eileencodes deleted the only-setup-shared-pools-if-we-have-a-connection branch August 5, 2022 17:07
eileencodes added a commit that referenced this pull request Aug 5, 2022
…-we-have-a-connection

Only setup shared pools if we have a connection
@eileencodes
Copy link
Member Author

I backported this to 7-0-stable and pushed before I realized one legacy connection handling test is failing. Working on a fix, if I can't find one I'll revert the one on 7-0-stable.

eileencodes added a commit that referenced this pull request Aug 5, 2022
PR #45773 broke legacy handling test fixtures and while I can fix this particular
error it breaks how shared pools are setup. I don't think this is the same kind
of buggy on legacy handling so let's leave that behavior and only change
the new handling.
eileencodes added a commit that referenced this pull request Aug 5, 2022
…-we-have-a-connection

Only setup shared pools if we have a connection
eileencodes added a commit that referenced this pull request Aug 5, 2022
PR #45773 broke legacy handling test fixtures and while I can fix this particular
error it breaks how shared pools are setup. I don't think this is the same kind
of buggy on legacy handling so let's leave that behavior and only change
the new handling.
eileencodes added a commit that referenced this pull request Aug 5, 2022
* In 7-0-stable it's `ActiveRecord.legacy_connection_handling` but in
6-0-stable it's `ActiveRecord::Base.legacy_connection_handling`.
* I don't really get why but since the transactional tests line was
removed the lines calling `establish_connection(:primary)` started
raising the deprecation warning saying that Base and primary won't be
treated the same in the future so I added some assertion blocks
around those.
@eileencodes
Copy link
Member Author

eileencodes commented Aug 5, 2022

Backported to 7-0-stable and 6-1-stable but note this is only handled for the new connection handling and not legacy handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArgumentError due to nil pool_config when calling connects_to
1 participant